import 'dart:math';

import 'package:chathouse/pages/expert/buyWallet/bank_transfer_cer_send.dart';
import 'package:chathouse/pages/expert/buyWallet/recharge_bank_card.dart';
import 'package:chathouse/public/Config.dart';
import 'package:chathouse/util/base_utils.dart';
import 'package:chathouse/widgets/base_appbar.dart';
import 'package:flutter/material.dart';
export 'package:get/get.dart';

import '../../../constant/app_constant.dart';
import '../../../model/privacy_bean.dart';
import 'package:chathouse/model/species.dart';

/// @class : recharge_bank_card
/// @date : 2023-03-02 20:06
/// @name : LFC
/// @description :银行卡充值页面（显示卡号信息的）
class BanCardRecharge extends StatefulWidget {
  Rows? row;

  BanCardRecharge(this.row, {Key? key}) : super(key: key);

  @override
  State<BanCardRecharge> createState() => _BanCardRechargeState();
}

class _BanCardRechargeState extends State<BanCardRecharge> {
  PrivacyBeanTool? result;
  String? orderId;
  @override
  void initState() {
    super.initState();
    Obj.showLoading();
    Apis.getPrivacy().then((response) {
      Obj.dismissLoading();
      result = PrivacyBeanTool.fromJson(response?.data);
      SpUtil.putString(AppConstant.bankName, result?.data?.bankName ?? "");
      SpUtil.putString(
          AppConstant.accountNumber, result?.data?.accountNumber ?? "");
      setState(() {});
    }).catchError((error) {
      Obj.dismissLoading();
      setState(() {});
    });
    loadTradingCode();
  }

  loadTradingCode() {
    Apis.getTradingCode({})
        .then((value){
      orderId = value?.data["msg"];
      setState(() {

      });
    })
        .onError((error, stackTrace){

    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: getAppBar(title: "Bank Transfer"),
      body: Column(
        children: [
          Column(
            children: [
              SizedBox(height: 40.w),
              Row(
                children: [
                  Text(
                    "訂單號     :",
                    style: getTextStyle(18.sp,
                        color: Colors.black, fontType: FontType.BOLD),
                  ),
                  SizedBox(width: 8.w),
                  Text(
                    orderId ?? "",
                    style: getTextStyle(18.sp,
                        color: Colors.black, fontType: FontType.BOLD),
                  )
                ],
              ),
              SizedBox(height: 14.w),
              Row(
                children: [
                  Text(
                    "服務内容 ：",
                    style: getTextStyle(18.sp,
                        color: Colors.black, fontType: FontType.BOLD),
                  ),
                  SizedBox(width: 8.w),
                  Text(
                    "購買金幣",
                    style: getTextStyle(18.sp,
                        color: Colors.black, fontType: FontType.BOLD),
                  )
                ],
              ),
              SizedBox(height: 14.w),
              Row(
                children: [
                  Text(
                    "充值金額 ：",
                    style: getTextStyle(18.sp,
                        color: Colors.black, fontType: FontType.BOLD),
                  ),
                  SizedBox(width: 8.w),
                  Text(
                    "HK${widget.row!.moneyAmount}",
                    style: getTextStyle(18.sp,
                        color: MyColors.green_69157154,
                        fontType: FontType.BOLD),
                  )
                ],
              ),
              SizedBox(height: 20.w),
            ],
          ).setContainer(margin: EdgeInsets.symmetric(horizontal: 30.w)),
          Container(
              width: double.infinity,
              height: 0.5.w,
              color: MyColors.gary_155155155),
          Column(
            children: [
              SizedBox(height: 20.w),
              Text(
                "*請安排轉數快FPS 轉帳以上金額至下列轉數快ID 帳號及註明訂單號碼以便跟進. 轉數成功證明可按下到〔我已付款〕上載截圖.",
                style: getTextStyle(18.sp,
                    color: MyColors.red_2166474, fontType: FontType.BOLD),
              ),
              SizedBox(height: 30.w),
              Row(
                children: [
                  Text(
                    "付款方法 ：",
                    style: getTextStyle(18.sp,
                        color: Colors.black, fontType: FontType.BOLD),
                  ),
                  SizedBox(width: 8.w),
                  Text(
                    result?.data?.bankName ?? "",
                    style: getTextStyle(18.sp,
                        color: Colors.black, fontType: FontType.BOLD),
                  )
                ],
              ),
              SizedBox(height: 14.w),
              Row(
                children: [
                  Text(
                    "轉數快ID. ：",
                    style: getTextStyle(18.sp,
                        color: Colors.black, fontType: FontType.BOLD),
                  ),
                  SizedBox(width: 8.w),
                  Text(
                    result?.data?.accountNumber ?? "",
                    style: getTextStyle(18.sp,
                        color: Colors.black, fontType: FontType.BOLD),
                  )
                ],
              ),
              SizedBox(height: 14.w),
              Row(
                children: [
                  Text(
                    "交易備註 ：",
                    style: getTextStyle(18.sp,
                        color: Colors.black, fontType: FontType.BOLD),
                  ),
                  SizedBox(width: 8.w),
                  Text(
                    " [ 您的訂購號 ]",
                    style: getTextStyle(18.sp,
                        color: Colors.black, fontType: FontType.BOLD),
                  )
                ],
              ),
            ],
          ).setContainer(margin: EdgeInsets.symmetric(horizontal: 30.w)),
          const Spacer(),
          Text(
            "我已付款",
            style: getTextStyle(20.sp,
                fontType: FontType.BOLD, color: Colors.white),
          )
              .setContainer(
                  alignment: Alignment.center,
                  width: 255.w,
                  margin: EdgeInsets.only(bottom: 50.w),
                  padding: EdgeInsets.symmetric(vertical: 6.w),
                  decoration: BoxDecoration(
                      color: MyColors.gary_69157154,
                      borderRadius: BorderRadius.circular(26.w)))
              .setOnClickListener(() {
            Get.to(BankTransferCerSendPage(widget.row,orderId));
          })
        ],
      ),
    );
  }
}
